package reflect;


import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();

        //say(String info)
        Method m = cls.getMethod("say",String.class);
        m.invoke(o,"hello~~");//p.say("hello~~")

        //say(String info,int sum)
        Method m2 = cls.getMethod("say",String.class,int.class);
        m2.invoke(o, "嘿嘿",5);

    }
}
